package com.neusoft.demo3.config;

import com.neusoft.demo3.bean.SysOrder;

public class AjaxResult {

    private Integer code;
    private String message;
    private Object data;


    public AjaxResult(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static AjaxResult success(Object data) {//成功
       AjaxResult ajaxResult= new AjaxResult(200,"success",data);
        return ajaxResult;
    }
    public static AjaxResult success() {
        // 无数据时，data可以传null，不影响前端解析
        return new AjaxResult(200, "success", null);
    }
    public static AjaxResult fail(Object data) {//失败
        AjaxResult ajaxResult= new AjaxResult(500,"fail",null);
        return ajaxResult;
    }

    public static AjaxResult exception(Object data) {//异常
        AjaxResult ajaxResult= new AjaxResult(700,"exception",null);
        return ajaxResult;
    }
    public static AjaxResult error(String message) {
        return new AjaxResult(400, message, null);
    }
    public static AjaxResult success(String message, Object data) {
        return new AjaxResult(200, message, data);
    }

}
